package com.cdks.wuxiu.api.service.mongo;

import com.cdks.wuxiu.entity.mongodb.QuizQuestionInfo;

import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;


/**
 * 心理测试问题 服务实现类
 */
@Slf4j
@Service
public class QuizQuestionInfoServiceImpl implements QuizQuestionInfoService {
    @Resource
    private MongoTemplate mongoTemplate;


    @Override
    public QuizQuestionInfo getByIndex(Long topicId, int index) {
        Query query = Query.query(Criteria.where("topicId").is(topicId).and("index").is(index));

        return mongoTemplate.findOne(query, QuizQuestionInfo.class);
    }
}
